﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;

namespace GameName1
{
    class BonusAlienController : GameObject
    {
        private Random rnd;
        private double _lastSpawnTime;

        public BonusAlienController()
        {
            rnd = new Random();
        }

        public override void Update(GameTime gameTime)
        {
            if (GameObjectsManager.GetInstance().GetAllObjectsOfType<BonusAlien>().Count == 0 && gameTime.TotalGameTime.TotalMilliseconds > _lastSpawnTime + 1000)
            {
                _lastSpawnTime = gameTime.TotalGameTime.TotalMilliseconds;
                if (rnd.NextDouble() > 0.75)
                {
                    BonusAlien bonusAlien;
                    rnd = new Random();
                    var x = rnd.NextDouble();
                    Console.Out.WriteLine(x);
                    if (x > 0.5)
                    {
                        bonusAlien = new BonusAlien(new Vector2(-58, 35), 1);
                    }
                    else
                    {
                        bonusAlien = new BonusAlien(new Vector2(ScreenManager.GetInstance().Resolution.X-1, 35), -1);
                    }
                    GameObjectsManager.GetInstance().Instantiate(bonusAlien);
                }
            }
        }
    }
}
